// pages/list/list.js
var api = require('../../utils/api.js')

var app = getApp();
var toastSetTimeout;
Page({

  /**
   * 页面的初始数据
   */
  data: Object.assign({
      tabActive: 'rank',
      list: [],
      board: {},
      paged: 1,
      loading: false  
  },app.globalData.data),
   
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (option) {
   
    this.loading(true)
    api.getOnline(option.type,1)
      .then(data => {
        this.setData({
          type: option.type,
          list: data.song_list,
          board: data.billboard,
          loading: false
        })
      })
  },
  nextpage: function(e){
    var paged = this.data.paged + 1;
    this.loading(true)
    api.getOnline(this.dats.type,paged).then(data => {
      this.setData({
        paged: paged ,
        list: this.data.list.concat(data.song_list),
        loading: false
      })
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    wx.setNavigationBarTitle({title: '在线音乐'})
  },
  loading:function(text){
    this.setData({loading: text})
  }
  
})